package com.atguigu.staticservice.schedule;

import com.aiguigu.commonutils.DateUtil;
import com.atguigu.staticservice.service.StatisticsDailyService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @title: ScheduldTask
 * @Author danghailiang
 * @Date: 2022/10/11 17:49
 * @Version 1.0
 */
@Component
public class ScheduledTask {

    @Resource
    private StatisticsDailyService statisticsDailyService;

    /**
     * second
     * minute
     * hour
     * day of month
     * month
     * day of week
     *
     * http://cron.qqe2.com/
     * 每五秒执行一
     */
//    @Scheduled(cron = "0/5 * * * * ?")
    public  void task1(){
        System.out.println("*********++++++++++++*****执行了");
    }

    @Scheduled(cron = "0 0 7 * * ?")
    public void task2(){
        statisticsDailyService.registerCount(DateUtil.addDays(new Date(),-1).toString());
    }
}
